package com.lujianfei.gamelearn

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.viewmodel.compose.viewModel
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.lujianfei.gamelearn.mahjong.MahjongCanvas
import com.lujianfei.gamelearn.mahjong.MahjongFactory
import com.lujianfei.gamelearn.mahjong.MahjongViewModel
import com.lujianfei.gamelearn.ui.theme.GamelearnTheme

class MainActivity : ComponentActivity() {


    @Composable
    private fun SetStatusBarLight() {
        val systemUiController = rememberSystemUiController()
        SideEffect {
            systemUiController.systemBarsDarkContentEnabled = false
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        MahjongFactory.instance.init()
        enableEdgeToEdge()
        setContent {
            SetStatusBarLight()
            GamelearnTheme {
                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
                    val viewModel:MainViewModel = viewModel()
                    Box(modifier = Modifier.padding(innerPadding)) {
                        MahjongCanvas()
                        IconButton(onClick = {

                        }) {
                             Icon(Icons.Default.Menu, contentDescription = "Menu")
                        }
                    }
                }
            }
        }
    }
}

@Preview
@Composable
fun PreviewUI() {
}
